import request from '@/utils/request'
import {URL} from '@/utils/url'
import axios from 'axios'

//注册register
export const register = ({name,email,password,code}) => {
    return request.post('auth/register',{name,email,password,code})
}

//登录
const login = ({email,password,checkPass}) => {
    return request.post('auth/login',{email,password,checkPass})
}

//获取用户信息
const getUserInfo = () => {
    return request.get('auth/userInfo')
}

//获取其他用户信息
export function getUserInfoById(uid){
    const url = URL + 'api/userInfo'
    const data ={
      'uid': uid,
    }
    return axios.get(url,{
      params: data
    }).then(res => {
      return Promise.resolve(res)
    })
}

//修改信息
const modifyInfo = ({name,sign}) => {
    return request.post('auth/modifyInfo',{name,sign})
}

//获取验证码
export const sendCode = (email) => {
  return request.post('code/send',{email})
}

export default{
    login,
    getUserInfo,
    modifyInfo,
}